package com.java.tutorials.jdk7.fileoperation;

import com.java.tutorials.Constants;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

/**
 * Created by xuzhike on 2016/1/25.
 * http://www.java2s.com/Code/Java/JDK-7/AtomicFileMove.htm
 * Atomic File Move
 */
public class AtomicFileMove {
    public static void main(String[] args) throws Exception{
        Path sourceFile = Paths.get(Constants.TEST_FILE_WITH_PATH);
        Path destinationFile = Paths.get(Constants.ANOTHER_TEST_PATH+"test4.txt");
        Files.move(sourceFile, destinationFile, StandardCopyOption.ATOMIC_MOVE);

    }
}
